﻿@model PagedList.IPagedList<CultuRAM.Models.Resource>


@if (Model != null && Model.Count() != 0){
 
    <table id="tableRes" class="table table-hover table-striped table-bordered" style="width:100%;">
    <tr>
        <th style="width: 20%;">
            @Html.DisplayNameFor(model => model.FirstOrDefault().ResourceType.ResType)
        </th>
        <th style="width: 40%;">
            @Html.DisplayNameFor(model => model.FirstOrDefault().Name)
        </th>
        <th style="width: 40%;">
            @Html.DisplayNameFor(model => model.FirstOrDefault().File)
        </th>
    </tr>
        @foreach (var item in Model)
        {
            <tr id="@item.ResId">
                <td>
                    @Html.DisplayFor(modelItem => item.ResourceType.ResType)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Name)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.File)
                </td>
            </tr>
        }
    </table>
  
    <div class="row-fluid pagination-botton"> 
        <div class="span6">      
       
          @Html.Raw(@Ajax.ActionLink("replacetxt", "CreatePv", "Resource",new { page = Model.PageNumber, idEvent = Model.FirstOrDefault().Event.EventId},
                             new AjaxOptions
                                 {
                                     UpdateTargetId="tabEventResRight", 
                                     InsertionMode = InsertionMode.Replace, 
                                     HttpMethod = "GET", 
                                     OnComplete = "ResBgColorAdd()"
                                 }, new { @class = "btn btn-success btn-xs", id="btnAddRes" }) 
		                        .ToHtmlString().Replace("replacetxt", "<i class=\"icon-plus icon-white\"></i> Adicionar"))
         
          @Html.Raw(@Ajax.ActionLink("replacetxt", "EditPv", "Resource", new { page = Model.PageNumber},
                             new AjaxOptions
                                 {
                                     UpdateTargetId="tabEventResRight", 
                                     InsertionMode = InsertionMode.Replace, 
                                     HttpMethod = "GET",
                                     OnComplete = "ResBgColorEdit()" 
                                 }, new { @class = "btn btn-warning btn-xs", id="btnEditRes" })
		                        .ToHtmlString().Replace("replacetxt", "<i class=\"icon-pencil icon-white\"></i> Editar"))	
           
          @Html.Raw(@Ajax.ActionLink("replacetxt", "DeletePv", "Resource", new { page = Model.PageNumber},
                             new AjaxOptions
                                 {
                                     UpdateTargetId = "tabEventResRight",
                                     InsertionMode = InsertionMode.Replace,
                                     HttpMethod = "GET",
                                     OnComplete = "ResBgColorDel()"
                                 }, new { @class = "btn btn-danger btn-xs", id = "btnDelRes" }) 
		                        .ToHtmlString().Replace("replacetxt", "<i class=\"icon-remove icon-white\"></i> Eliminar"))
        </div> 
    
        <div class="span6">
            <div class="pagination" style="margin: 0">
                <ul>
                    @if (Model.HasPreviousPage)
                    {
                        <li>
                            @Ajax.ActionLink("«", "IndexPv", "Resource", new { page = 1, idEvent = Model.FirstOrDefault().Event.EventId},
                                             new AjaxOptions
                                                 {
                                                     UpdateTargetId="tabEventResLeft", 
                                                     InsertionMode = InsertionMode.Replace, 
                                                     HttpMethod = "GET" 
                                                 }, new { @class = ""}) 
                        </li> 
                        <li>
                            @Ajax.ActionLink("<", "IndexPv", "Resource", new { page = Model.PageNumber - 1, idEvent = Model.FirstOrDefault().Event.EventId},
                                             new AjaxOptions
                                                 {
                                                     UpdateTargetId="tabEventResLeft", 
                                                     InsertionMode = InsertionMode.Replace, 
                                                     HttpMethod = "GET" 
                                                 }, new { @class = ""}) 
                        </li>
                        <li class="">
                            <a href="#" data-original-title="" title="" class="">
                                Página <b> @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)</b> de <b> @Model.PageCount </b>
                            </a>
                        </li>  
                    }
                    else
                    {
                        <li class="disabled"><a href="#" data-original-title="" title="" class="">«</a></li> 
                        <li class="disabled"><a href="#" data-original-title="" title="" class=""><</a></li> 
                        <li class="">
                            <a href="#" data-original-title="" title="" class="disabled">
                                Página <b> @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)</b> de <b> @Model.PageCount </b>
                            </a>
                        </li> 
                    }
                    <li>
                    @if (Model.HasNextPage)
                    {
                        <li>
                            @Ajax.ActionLink(">", "IndexPv", "Resource", new { page = Model.PageNumber + 1, idEvent = Model.FirstOrDefault().Event.EventId},
                                             new AjaxOptions
                                                 {
                                                     UpdateTargetId="tabEventResLeft", 
                                                     InsertionMode = InsertionMode.Replace, 
                                                     HttpMethod = "GET" 
                                                 }, new { @class = ""}) 
                        </li>
                        <li>
                            @Ajax.ActionLink("»", "IndexPv", "Resource", new { page = Model.PageCount, idEvent = Model.FirstOrDefault().Event.EventId},
                                             new AjaxOptions
                                                 {
                                                     UpdateTargetId="tabEventResLeft", 
                                                     InsertionMode = InsertionMode.Replace, 
                                                     HttpMethod = "GET" 
                                                 }, new { @class = ""}) 
                        </li>
                    }
                    else
                    {
                        <li class="disabled"><a href="#" data-original-title="" title="" class="disabled">></a></li> 
                        <li class="disabled"><a href="#" data-original-title="" title="" class="disabled">»</a></li>
                    }
                </ul>
            </div>  

        </div>

    </div>
    

}else{
    
    <div id="msgInf_" class="alert alert-warning" style="margin-top: 10px;">Este evento não tem Recursos definidos!</div>
    <br/>
    <p>
          @Html.Raw(@Ajax.ActionLink("replacetxt", "CreatePv", "Resource",new { idEvent = ViewBag.idEv},
                             new AjaxOptions
                                 {
                                     UpdateTargetId="tabEventResRight", 
                                     InsertionMode = InsertionMode.Replace, 
                                     HttpMethod = "GET", 
                                     OnComplete = "ResBgColorAdd()"
                                 }, new { @class = "btn btn-success btn-xs", id="btnAddRes" }) 
		                        .ToHtmlString().Replace("replacetxt", "<i class=\"icon-plus icon-white\"></i> Adicionar"))
    </p>    
}


@Scripts.Render("~/bundles/culturam")